package store.lunangangster.bpmn.model;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * 一个Bpmn文件的动态表示
 *
 * @author cwk
 * @version 1.0
 */
public class BpmnModel {

  protected Map<Class<? extends BaseElement>, Map<String, BaseElement>> elementMap = new HashMap<>();
  protected List<Process> processes = new ArrayList<>();
  protected String targetNamespace;
  protected String defaultNamespace;
  protected Map<String, String> namespaceMap = new LinkedHashMap<>();

  public List<Process> getProcesses() {
    return processes;
  }

  public void setProcesses(List<Process> processes) {
    this.processes = processes;
  }

  public String getDefaultNamespace() {
    return defaultNamespace;
  }

  public void setDefaultNamespace(String defaultNamespace) {
    this.defaultNamespace = defaultNamespace;
  }

  public String getTargetNamespace() {
    return targetNamespace;
  }

  public void setTargetNamespace(String targetNamespace) {
    this.targetNamespace = targetNamespace;
  }

  public Map<String, String> getNamespaceMap() {
    return namespaceMap;
  }

  public void setNamespaceMap(Map<String, String> namespaceMap) {
    this.namespaceMap = namespaceMap;
  }

  public void addNamespace(String prefix, String namespace) {
    this.namespaceMap.put(prefix, namespace);
  }

  public Map<Class<? extends BaseElement>, Map<String, BaseElement>> getElementMap() {
    return elementMap;
  }

 public void addToElementMap(BaseElement element) {
    if (element != null) {
      if (!elementMap.containsKey(element.getClass())) {
        elementMap.put(element.getClass(), new HashMap<>());
      }
      elementMap.get(element.getClass()).put(element.getId(), element);
    }
 }

}
